package com.zzyl.common.utils;

import java.time.LocalDateTime;
import java.time.LocalTime;

public class LocalDateTimeUtil {

    public static LocalDateTime of(long timestamp) {
        return LocalDateTime.ofInstant(java.time.Instant.ofEpochMilli(timestamp), java.time.ZoneId.systemDefault());
    }

    public static LocalDateTime startOfDay(LocalDateTime time) {
        return time.with(LocalTime.MIN);
    }

    public static LocalDateTime endOfDay(LocalDateTime time) {
        return time.with(LocalTime.MAX);
    }

    /*
    //LocalDateTimeUtil工具类的用法
    @Autowired
    private ReservationMapper reservationMapper;

    public List<TimeCountVO> getReservationCountByTime(long timestamp) {
        LocalDateTime ldt = LocalDateTimeUtil.of(timestamp);
        LocalDateTime startTime = LocalDateTimeUtil.startOfDay(ldt);
        LocalDateTime endTime = LocalDateTimeUtil.endOfDay(ldt);

        return reservationMapper.countReservationsByTime(startTime, endTime);
    }
     */
}